package com.ruoyi.web.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.web.domain.ContactPhone;
import com.ruoyi.web.service.IContactPhoneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "联系我们的电话号码控制层")
@RequestMapping("/contactPhone")
public class ContactPhoneController extends BaseController {

    @Autowired
    private IContactPhoneService contactPhoneService;

    @GetMapping("/list")
    @ApiOperation("查询联系我们的电话号码列表")
    public TableDataInfo getPhoneNumList(ContactPhone contactPhone) {
        startPage();
        List<ContactPhone> list = contactPhoneService.getList(contactPhone);
        return getDataTable(list);
    }

    @GetMapping
    @ApiOperation("查询当前联系我们的电话号码")
    public AjaxResult getPhoneNum() {
        return AjaxResult.success(contactPhoneService.getPhoneNum());
    }

    @GetMapping("/getEmail")
    @ApiOperation("查询当前联系我们的联系邮箱")
    public AjaxResult getEmail() {
        return AjaxResult.success(contactPhoneService.getEmail());
    }

    @PutMapping
    @ApiOperation("修改电话号码")
    public AjaxResult update(@RequestBody ContactPhone contactPhone) {
        contactPhoneService.update(contactPhone);
        return AjaxResult.success();
    }
}
